@layout("/common/_testloginreCommond.html"){
<title>咿呀培训系统 - 登录</title>
<body class="loginbody">
<div class="outside img-responsive loginbg">
    <!--logo-->
    <div class="logogif"><img src="${ctxPath}/static/img/images/u16.gif"></div>
    <!--input-->
    <div class="input">
        <input type="text" id="userName" name="firstname form-control" placeholder="用户名"/><br>
        <input type="password" id="passWord" name="password form-control" placeholder="密码"/>
        <input type="text" id="kaptcha1" name="firstname form-control" placeholder="验证码"/><br>
    </div>
    <div class="kaptcha">
        <img src="${ctxPath}/kaptcha" id="kaptcha" width="100%" height="100%"/>
    </div>
    <!--login-->
    <div class="login">
        <button type="submit" class="btn btn-default" id="submit_login">登录</button>
    </div>
    <!--zhuce-->
    <!-- <div class="zhuce">-->
    <!--  <span style="float: left;">忘记密码</span>-->
    <!--<span>没有账号?点我注册</span>-->
    <!-- </div>-->
</div>
<script>
    $(function () {
        $("#kaptcha").on('click', function () {
            $("#kaptcha").attr('src', '${ctxPath}/kaptcha?' + Math.floor(Math.random() * 100)).fadeIn();
        });
    });
    $('#btn_reset').click(function () {
        document.getElementById('userName').value = "";
        document.getElementById('passWord').value = "";
        document.getElementById('kaptcha1').value = "";
    })
    $('.zhuce').unbind().on('click', function () {
        window.location.href = "${ctxPath}/register";
    })
    $('#submit_login').click(function () {
        var userName = $('#userName').val();
        var passWord = $('#passWord').val();
        var kaptcha = $('#kaptcha1').val();
        $.ajax({
            url: "${ctxPath}/login",
            type: "post",
            data: {
                "username": userName,
                "kaptcha": kaptcha,
                "password": passWord
            },
            success: function (data) {
                alert('登录成功!');
                window.location.href = "${ctxPath}/testMenu";
            },
            error: function (data) {
                alert('账户,密码或验证码错误，请稍后再试!');
                window.location.href = "${ctxPath}/login";
            }
        });
    })
    $("#kaptcha1").on('click', function () {
        $("#kaptcha1").attr('src', '${ctxPath}/kaptcha?' + Math.floor(Math.random() * 100)).fadeIn();
    });
</script>
@}
